package com.ims.system.service.impl;

import java.util.List;

import com.ims.common.core.domain.entity.SysUser;
import com.ims.common.core.domain.model.LoginUser;
import com.ims.common.utils.DateUtils;
import com.ims.common.utils.ImCodeUtils;
import com.ims.common.utils.SecurityUtils;
import com.ims.system.domain.TSysSite;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ims.system.mapper.TSysCustomerMapper;
import com.ims.system.domain.TSysCustomer;
import com.ims.system.service.ITSysCustomerService;

/**
 * 系统客户Service业务层处理
 *
 * @author IMS
 * @date 2024-05-25
 */
@Service
public class TSysCustomerServiceImpl implements ITSysCustomerService
{
    @Autowired
    private TSysCustomerMapper tSysCustomerMapper;

    /**
     * 查询系统客户
     *
     * @param id 系统客户主键
     * @return 系统客户
     */
    @Override
    public TSysCustomer selectTSysCustomerById(Long id)
    {
        return tSysCustomerMapper.selectTSysCustomerById(id);
    }

    /**
     * 查询系统客户列表
     *
     * @param tSysCustomer 系统客户
     * @return 系统客户
     */
    @Override
    public List<TSysCustomer> selectTSysCustomerList(TSysCustomer tSysCustomer)
    {
        return tSysCustomerMapper.selectTSysCustomerList(tSysCustomer);
    }

    /**
     * 新增系统客户
     *
     * @param tSysCustomer 系统客户
     * @return 结果
     */
    @Override
    public int insertTSysCustomer(TSysCustomer tSysCustomer)
    {
        TSysCustomer tSysCustomerCondition = new TSysCustomer();
        List<TSysCustomer> sysCustomers = tSysCustomerMapper.selectTSysCustomerList(tSysCustomerCondition);
        tSysCustomer.setCustId(ImCodeUtils.getCustId(sysCustomers.size()));
        tSysCustomer.setCreateTime(DateUtils.getNowDate());
        return tSysCustomerMapper.insertTSysCustomer(tSysCustomer);
    }

    /**
     * 修改系统客户
     *
     * @param tSysCustomer 系统客户
     * @return 结果
     */
    @Override
    public int updateTSysCustomer(TSysCustomer tSysCustomer)
    {
        tSysCustomer.setUpdateTime(DateUtils.getNowDate());
        return tSysCustomerMapper.updateTSysCustomer(tSysCustomer);
    }

    /**
     * 批量删除系统客户
     *
     * @param ids 需要删除的系统客户主键
     * @return 结果
     */
    @Override
    public int deleteTSysCustomerByIds(Long[] ids)
    {
        return tSysCustomerMapper.deleteTSysCustomerByIds(ids);
    }

    /**
     * 删除系统客户信息
     *
     * @param id 系统客户主键
     * @return 结果
     */
    @Override
    public int deleteTSysCustomerById(Long id)
    {
        return tSysCustomerMapper.deleteTSysCustomerById(id);
    }
}
